﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DXApplicationTangche.UC.订单一览新.销售确认单
{
    public partial class Form客套顺丰发运匹配 : DevExpress.XtraEditors.XtraForm
    {
        private List<CustomerTagRecordDTO> customerTagRecordDTOs确认 = new List<CustomerTagRecordDTO>();
        private List<CustomerTagRecordDTO> customerTagRecordDTOs = new List<CustomerTagRecordDTO>();
        private List<CustomerTagRecordDTO> customerTagRecordDTOs扫码 = new List<CustomerTagRecordDTO>();
        public Form客套顺丰发运匹配(List<CustomerTagRecordDTO> customerTagRecordDTOs)
        {
            InitializeComponent();
            this.customerTagRecordDTOs = customerTagRecordDTOs;
            this.gridControl待发运记录.DataSource = customerTagRecordDTOs;
            this.gridView待发运记录.RefreshData();
        }

        private void simpleButton顺丰发运出库_Click(object sender, EventArgs e)
        {
            new Form客户套号顺丰发运预览(this.customerTagRecordDTOs扫码).ShowDialog();
        }

        private void gridView待发运记录_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
        {
            if (e.Column.Name.Equals("gridColumn尺码"))
            {
                if (!String.IsNullOrWhiteSpace(e.DisplayText))
                {
                    try { e.DisplayText = e.DisplayText.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
                }
            }
        }

        private void textBox扫码_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 13)
            {
                for (int i = this.customerTagRecordDTOs.Count-1; i >= 0; i--)
                {
                    if (this.textBox扫码.Text.Trim().Equals(this.customerTagRecordDTOs[i].barcode))
                    {
                        if (!this.customerTagRecordDTOs扫码.Contains(this.customerTagRecordDTOs[i]))
                        {
                            this.customerTagRecordDTOs扫码.Add(this.customerTagRecordDTOs[i]);
                            this.customerTagRecordDTOs.Remove(this.customerTagRecordDTOs[i]);
                            break;
                        }
                    }
                }
                this.gridControl扫码匹配.DataSource = this.customerTagRecordDTOs扫码;
                this.gridView扫码匹配.RefreshData();
                this.gridControl待发运记录.DataSource = this.customerTagRecordDTOs;
                this.gridView待发运记录.RefreshData();
                this.textBox扫码.Clear();
            }
        }

        private void Form客套顺丰发运匹配_Load(object sender, EventArgs e)
        {
            this.ActiveControl = this.textBox扫码;
        }
    }
}
